<?php
/**
 * Created by PhpStorm.
 * User: medivh
 * Date: 15-6-25
 * Time: 上午9:33
 */
namespace YouXiMi\Controller;
use Think\Controller;

/**
 * Class QuizController
 * @package YouXiMi\Controller
 * 竞猜功能
 */
Class QuizController extends Controller{
    /**
     * 竞猜列表页
     */
    public function home(){
        switch(I('data')){
            case 'today':
                $this->ajaxReturn(self::day("today"),"EVAL");
                break;
            case 'tomorrow':
                $this->ajaxReturn(self::day("tomorrow"),"EVAL");
                break;
            case 'after':
                $this->ajaxReturn(self::day("after"),"EVAL");
                break;
            case 'record':
                $this->ajaxReturn(self::record(),"EVAL");
                break;
            default:
                $this->default = M('quiz_ranks')->where("`start` > ".strtotime(date('Y-m-d',time()))." AND `start` < ".((strtotime(date('Y-m-d',time())))+86400-1)."")->select();
                $this->display();
        }
    }
    public function day($day){
        $l = "";
        if($day == "today"){
            $l = strtotime(date('Y-m-d',time()));
        }elseif($day == "tomorrow"){
            $l = strtotime(date('Y-m-d',time()))+86400;
        }elseif($day == "after"){
            $l = strtotime(date('Y-m-d',time()))+86400*2;
        }
        $select = M('quiz_ranks')->where("`start` > ".$l." AND `start` < ".($l+86400-1)."")->select();
        $tpl = '';
        foreach($select as $key){
            $tpl .= "
            <div class='row'>
                <div class='col-xs-2'>
                    <div class='time'>
                        <span style='display:block;margin-left:-18px'> ".date('H:i',$key['start'])."</span>
                        <div class='nz'></div>
                    </div>
                </div>
                <div class='col-xs-10 bj-border'>
                    <div class='msg'>
                        <div class='row'>
                            <div style='padding:0;margin:0' class='col-xs-4'>
                                <img class='msg-img msg-title' src='".$key['ranksyurl']."'>
                                <span class='msg-title'>".$key['ranksy']."</span>
                            </div>
                            <div style='padding:0;margin:0' class='col-xs-4'>
                                <span class='game-title'>".$key['game']."</span>
                                <p align='center' class='more'></p>
                            </div>
                            <div style='padding:0;margin:0' class='col-xs-4'>
                                <img class='msg-img msg-title' src='".$key['ranksnurl']."'>
                                <span class='msg-title'>".$key['ranksn']."</span>
                            </div>
                        </div>
                        <div class='row xl'>
                            <p class='xq-tz'><span class='tz'>投注</span><span class='xq'  style='color:#CCC'>详情</span></p>
                            <div class='row new-margin'>
                                <div style='padding:0;margin:0' class='col-xs-4'>
                                    <img class='msg-img msg-title' src='".$key['ranksyurl']."'>
                                    <span class='msg-title'>".$key['ranksy']."</span>
                                </div>
                                <div style='padding:0;margin:0' class='col-xs-4'>
                                    <div class='btn-now'>
                                        <div class='btn-group'>
                                            <button type='button' class='btn btn-default dropdown-toggle' data-toggle='dropdown' aria-expanded='false'>
                选择 <span class='caret'></span>
                                            </button>
                                            <ul class='dropdown-menu' role='menu'>
                                                <li><a href='#'>".$key['ranksy']."</a></li>
                                                <li><a href='#'>".$key['ranksn']."</a></li>
                                            </ul>
                                        </div>
                                    </div>

                                    <div class='btn-now'>
                                        <div class='btn-group'>
                                            <button type='button' class='btn btn-default dropdown-toggle' data-toggle='dropdown' aria-expanded='false'>
                金额 <span class='caret'></span>
                                            </button>
                                            <ul class='dropdown-menu' role='menu'>
                                                <li><a href='#'>5金币</a></li>
                                                <li><a href='#'>10金币</a></li>
                                                <li><a href='#'>15金币</a></li>
                                                <li><a href='#'>20金币</a></li>
                                                <li><a href='#'>25金币</a></li>
                                            </ul>
                                        </div>
                                    </div>

                                    <div class='btn-now' style='width: 50px'>
                                        <div class='btn-group'>
                                            <button type='button' class='btn btn-default dropdown-toggle' data-toggle='dropdown' aria-expanded='false'>
                结算
                                            </button>
                                        </div>
                                    </div>
                                </div>
                                <div style='padding:0;margin:0' class='col-xs-4'>
                                    <img class='msg-img msg-title' src='".$key['ranksnurl']."'>
                                    <span class='msg-title'>".$key['ranksn']."</span>
                                </div>
                            </div>
                            <div class='jdt'>
                                <div class='left-pl'><span class='wz'>赔率100%</span></div>
                                <div class='center-pj'><span class='wz'>平局</span></div>
                                <div class='right-pl'><span class='wz'>赔率100%</span></div>
                            </div>
                            <div class='xq-content'>
                                <p>".$key['details']."</p>
                            </div>
                            <p align='center' class='more-callback'></p>
                        </div>
                    </div>
                </div>
            </div>
        </foreach>
                    ";
        }
        return $tpl;
    }
    /**
     * 调取用户投注记录
     */
    public function record(){
        $tpl = "
                    <div class='row'>
        <div class='col-xs-3 no-margin'>
            <span class='left-table' style='border-left: 0'>日期</span>
        </div>
        <div class='col-xs-9 no-margin'>
            <span style='width: 20%;'>时间</span>
            <span style='width: 40%;'>赛事</span>
            <span style='width:20%'>投注</span>
            <span class='right-table' style='width: 20%;border-right: 0'>收益</span>
        </div>
    </div>
    <div class='row list-table'>
        <div class='col-xs-3 no-margin'>
            <span class='left-table' style='border:0'>2015-05-09</span>
        </div>
        <div class='col-xs-9 no-margin'>
            <span style='width: 20%;'>18:00</span>
            <span style='width: 40%;'>
                <p>英雄梁萌</p>
                <p>VG-GT</p>
            </span>
            <span style='width:20%'>300</span>
            <span class='right-table' style='width: 20%;border-right: 0'>
                <font class='math-plus'>+</font>500
            </span>
        </div>
    </div>

    <div class='row list-table'>
        <div class='col-xs-3 no-margin'>
            <span class='left-table' style='border:0'></span>
        </div>
        <div class='col-xs-9 no-margin'>
            <span style='width: 20%;'>18:00</span>
            <span style='width: 40%;'>
                <p>英雄梁萌</p>
                <p>VG-GT</p>
            </span>
            <span style='width:20%'>300</span>
            <span class='right-table' style='width: 20%;border-right: 0'>
                <font class='math-remove'>-</font>500
            </span>
        </div>
    </div>

    <div class='row list-table'>
        <div class='col-xs-3 no-margin'>
            <span class='left-table' style='border:0'></span>
        </div>
        <div class='col-xs-9 no-margin'>
            <span style='width: 20%;'>18:00</span>
            <span style='width: 40%;'>
                <p>英雄梁萌</p>
                <p>VG-GT</p>
            </span>
            <span style='width:20%'>300</span>
            <span class='right-table' style='width: 20%;border-right: 0'>
                +500
            </span>
        </div>
    </div>

    <div class='row list-table'>
        <div class='col-xs-3 no-margin'>
            <span class='left-table' style='border:0'></span>
        </div>
        <div class='col-xs-9 no-margin'>
            <span style='width: 20%;'>18:00</span>
            <span style='width: 40%;'>
                <p>英雄梁萌</p>
                <p>VG-GT</p>
            </span>
            <span style='width:20%'>300</span>
            <span class='right-table' style='width: 20%;border-right: 0'>
                +500
            </span>
        </div>
    </div>

    <div class='row list-table'>
        <div class='col-xs-3 no-margin'>
            <span class='left-table' style='border:0'>2015-05-08</span>
        </div>
        <div class='col-xs-9 no-margin'>
            <span style='width: 20%;'>18:00</span>
            <span style='width: 40%;'>
                <p>英雄梁萌</p>
                <p>VG-GT</p>
            </span>
            <span style='width:20%'>300</span>
            <span class='right-table' style='width: 20%;border-right: 0'>
                +500
            </span>
        </div>
    </div>

    <div class='row list-table'>
        <div class='col-xs-3 no-margin'>
            <span class='left-table' style='border:0'></span>
        </div>
        <div class='col-xs-9 no-margin'>
            <span style='width: 20%;'>18:00</span>
            <span style='width: 40%;'>
                <p>英雄梁萌</p>
                <p>VG-GT</p>
            </span>
            <span style='width:20%'>300</span>
            <span class='right-table' style='width: 20%;border-right: 0'>
                +500
            </span>
        </div>
    </div>

    <div class='row list-table'>
        <div class='col-xs-3 no-margin'>
            <span class='left-table' style='border:0'></span>
        </div>
        <div class='col-xs-9 no-margin'>
            <span style='width: 20%;'>18:00</span>
            <span style='width: 40%;'>
                <p>英雄梁萌</p>
                <p>VG-GT</p>
            </span>
            <span style='width:20%'>300</span>
            <span class='right-table' style='width: 20%;border-right: 0'>
                +500
            </span>
        </div>
    </div>

    <div class='row list-table'>
        <div class='col-xs-3 no-margin'>
            <span class='left-table' style='border:0'>2015-05-07</span>
        </div>
        <div class='col-xs-9 no-margin'>
            <span style='width: 20%;'>18:00</span>
            <span style='width: 40%;'>
                <p>英雄梁萌</p>
                <p>VG-GT</p>
            </span>
            <span style='width:20%'>300</span>
            <span class='right-table' style='width: 20%;border-right: 0'>
                +500
            </span>
        </div>
    </div>

    <div class='row list-table'>
        <div class='col-xs-3 no-margin'>
            <span class='left-table' style='border:0'></span>
        </div>
        <div class='col-xs-9 no-margin'>
            <span style='width: 20%;'>18:00</span>
            <span style='width: 40%;'>
                <p>英雄梁萌</p>
                <p>VG-GT</p>
            </span>
            <span style='width:20%'>300</span>
            <span class='right-table' style='width: 20%;border-right: 0'>
                +500
            </span>
        </div>
    </div>

    <div class='row list-table'>
        <div class='col-xs-3 no-margin'>
            <span class='left-table' style='border:0'></span>
        </div>
        <div class='col-xs-9 no-margin'>
            <span style='width: 20%;'>18:00</span>
            <span style='width: 40%;'>
                <p>英雄梁萌</p>
                <p>VG-GT</p>
            </span>
            <span style='width:20%'>300</span>
            <span class='right-table' style='width: 20%;border-right: 0'>
                +500
            </span>
        </div>
    </div>

    <div class='row list-table'>
        <div class='col-xs-3 no-margin'>
            <span class='left-table' style='border:0'></span>
        </div>
        <div class='col-xs-9 no-margin'>
            <span style='width: 20%;'>18:00</span>
            <span style='width: 40%;'>
                <p>英雄梁萌</p>
                <p>VG-GT</p>
            </span>
            <span style='width:20%'>300</span>
            <span class='right-table' style='width: 20%;border-right: 0'>
                +500
            </span>
        </div>
    </div>

    <div class='row list-table'>
        <div class='col-xs-3 no-margin'>
            <span class='left-table' style='border:0'></span>
        </div>
        <div class='col-xs-9 no-margin'>
            <span style='width: 20%;'>18:00</span>
            <span style='width: 40%;'>
                <p>英雄梁萌</p>
                <p>VG-GT</p>
            </span>
            <span style='width:20%'>300</span>
            <span class='right-table' style='width: 20%;border-right: 0'>
                +500
            </span>
        </div>
    </div>
                ";
        return $tpl;
//        $this->display();
    }
}